//
//  ZYCProfileUserInfomationBottomView.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/21.
//

#import "ZYCProfileUserInfomationBottomView.h"
#import "ZYCGrowthFileCell.h"
#import "ZYCUserInfoModel.h"
@interface ZYCProfileUserInfomationBottomView ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *greenView;
@property (nonatomic, strong) UITableView *tableView;
@end
@implementation ZYCProfileUserInfomationBottomView


#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ZYCGrowthFileCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([ZYCGrowthFileCell class])];
    cell.sModel = self.dataSource[indexPath.row];
    return cell;
}
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01f;
}

-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60.0f;
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [UIView new];
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.bgView];
        [self.bgView addSubview:self.greenView];
        [self.bgView addSubview:self.titleLabel];
        [self addSubview:self.tableView];
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(self);
            make.height.mas_equalTo(43.0f);
        }];
        
        [self.greenView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.bgView);
            make.left.equalTo(self.bgView).offset(15.0f);
            make.size.mas_equalTo(CGSizeMake(2, 13.0f));
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.greenView);
            make.left.equalTo(self.greenView.mas_right).offset(3.5f);
        }];
        
        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self);
            make.top.equalTo(self.bgView.mas_bottom);
        }];
        
    }
    return self;
}

- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = HEX_RGB(@"#FAFAFA");
    }
    return _bgView;
}

- (UIView *)greenView {
    if (!_greenView) {
        _greenView = [[UIView alloc] init];
        _greenView.backgroundColor = HEX_RGB(@"41B166");
    }
    return _greenView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithString:@"关联学生" Font:kCustomFont(@"PingFangSC-Regular", 14.0f) titleColor:HEX_RGB(@"#41B166") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerClass:[ZYCGrowthFileCell class] forCellReuseIdentifier:NSStringFromClass([ZYCGrowthFileCell class])];
        _tableView.scrollEnabled = NO;
        _tableView.showsVerticalScrollIndicator = NO;
        if (@available(iOS 15.0, *)) {
            _tableView.sectionHeaderTopPadding = 0;
        }
    }
    return _tableView;
}
@end
